package br.ufrj.dcc.engine;

import java.io.File;

import javax.swing.*;

/**
 * Open File menu frame.
 * @author Pedro Rougemont
 *
 */
public class FileChooser extends JFrame{
	
	/** default serial version id. */
	private static final long serialVersionUID = 1L;
	
	JFileChooser fileChooser;
	
	public FileChooser(){
		fileChooser = new JFileChooser();
	}
	
	public File carregaArquivo() {
		fileChooser.showOpenDialog(FileChooser.this);
		File file = fileChooser.getSelectedFile();
		
		if (file.getName().endsWith(".txt") || 
				file.getName().endsWith(".arff") || 
					file.getName().endsWith(".csv")) {			
			return file;
		}
		else {
			throw new Error("Wrong file format!");
		}
	}
}